Geographical data is everywhere. In Statoil we use maps to keep track of the licenses, well/installation locations, we use maps to outline the prospects and plan oil/gas pipelines. Our internal ArcGIS database contains a lot of spatial data produced internally (shapefiles for basins, licenses, prospects/fields), as well as procured from external sources (IHS, Tellus, NPD, etc).
However you may still find yourself feeling you are “starting from scratch”. The truth is, you probably have geo data even if you don’t have column for longitude and latitude. These days, google knows everything, and if google knows it, you probably have coordinates.
NB! Google allows only 2500 requests per day through their API free of charge
library(ggmap)
library(dplyr)
statoil_locations <- c("statoil fornebu", "statoil forus", "statoil kontor stjoerdal", "statoil harstad", "statoil tjeldbergodden", "statoil mongstad", "statoil kaarstoe", "statoil melkoeya")
stl_loc_df <- statoil_locations %>%
geocode() %>% bind_cols(location=statoil_locations)
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=statoil%20fornebu&sensor=false
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=statoil%20forus&sensor=false
.Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=statoil%20kontor%20stjoerdal&sensor=false
.Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=statoil%20harstad&sensor=false
geocode failed with status OVER_QUERY_LIMIT, location = "statoil harstad".Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=statoil%20tjeldbergodden&sensor=false
.Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=statoil%20mongstad&sensor=false
geocode failed with status OVER_QUERY_LIMIT, location = "statoil mongstad".Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=statoil%20kaarstoe&sensor=false
.Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=statoil%20melkoeya&sensor=false
stl_loc_df
Let’s see if we can plot these:
library(leaflet)
p <- leaflet(stl_loc_df) %>%
addTiles() %>%
addMarkers(popup = ~location)
Assuming 'lon' and 'lat' are longitude and latitude, respectively
Data contains 2 rows with either missing or invalid lat/lon values and will be ignored
p
Not bad! Lets see if we can get some shapefiles to play with:
library(raster)
Loading required package: sp
Attaching package: 㤼㸱raster㤼㸲
The following object is masked from 㤼㸱package:dplyr㤼㸲:
select
norway_fylke <- getData('GADM',
country = 'NO',
level = 1)
p %>%
addPolygons(data = norway_fylke)